import { action, observable } from 'mobx-miniprogram'

export const store = observable({
  // 数据字段
  numbA: 1,
  numbB: 2,
  userType: 1,
  activeTabBar: 0,
  trolleyCount: 0,
  user: null,
  website: "https://moloo.top",
  
  // 计算属性
  get sum() {
    return this.numbA + this.numbB
  },
  // action方法，用来修改store中的数据
  setUserType: action(function(type) {
    this.userType = type
  }),
  setNumbA: action(function(step) {
    this.numbA += step
  }),
  setNumbB: action(function(step) {
    this.numbB += step
  }),
  updataActiveTabBar: action(function(index) {
    this.activeTabBar = index
  }),
  updataTrolleyCount: action(function(count) {
    this.trolleyCount = count
  }),
  setUser: action(function(user){
    this.user = user
  }),
  getUser: action(function(){
    return this.user
  }),
  getWebsite: action(function(){
    return this.website
  }),
})